package com.woniu.service.vo;

import com.woniu.entity.TestDetail;
import com.woniu.entity.TestOutside;
import com.woniu.entity.TestType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "esshowtestvos")
public class ShowTestVo {
    @Id
    private String testCode;
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String testName;
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String introduce;
    @Field(type = FieldType.Keyword)
    private String difficulty;
    @Field(type = FieldType.Keyword)
    private String testType;
    @Field(type = FieldType.Keyword)
    private String testPictureUrl;
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String simpleNote;
    @Field(type = FieldType.Keyword)
    private Date testCreateTime;
    @Field(type = FieldType.Integer)
    private Integer visitors;
    @Field(type = FieldType.Integer)
    private Integer usedNumber;
    @Field(type = FieldType.Integer)
    private Integer heatRange;
    @Field(type = FieldType.Keyword)
    private Integer parentType;

    /**
     * 给ShowTestVo赋值
     *
     * @param testOutside
     */
    public ShowTestVo(TestOutside testOutside, TestDetail testDetail, TestType testType) {
        this.testCreateTime = testOutside.getTestCreateTime();
        this.heatRange = testOutside.getHeatRange();
        this.testCode = testOutside.getTestCode().toString();
        this.testName = testOutside.getTestName();
        this.usedNumber = testOutside.getUserdNumbers();
        this.visitors = testOutside.getVisitors();
        this.testPictureUrl = testOutside.getTestPictureUrl();
        this.introduce = testDetail.getIntroduce();
        this.simpleNote = testDetail.getTestNote();
        this.testType = testType.getTypeName();
        this.parentType=testType.getParentType();
        if (testOutside.getDifficultyScore()==5)this.difficulty="简单";
        if (testOutside.getDifficultyScore()==10)this.difficulty="中等";
        if (testOutside.getDifficultyScore()==15)this.difficulty="困难";
    }




}
